<?php



namespace App\Http\Requests\Company;

use App\Http\Requests\ApiV2\BaseRequest;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;

class IssueRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:20',
            'video_id' => 'required',
            'content' => 'required',
            'course_id' => 'required',

        ];
    }

    public function messages()
    {

        return [
            'title.required' => __('请输入问题的简单描述'),
            'title.max' => __('问题的描述不能超过:size个字符', ['size' => 20]),
            'course_id.required' => __('请输入问题视频ID'),
            'video_id.required' => __('请输入问题课程ID'),
            'content.required' => __('请输入问题的详细描述'),

        ];
    }

    public function filldata()
    {
        $user = Auth::user();
        return [
            'user_id'=>Auth::id(),
            'title' => (string)$this->input('title', ''),
            'start_point'=>$this->input('start_point'),
            'content' => (string)$this->input('content', ''),
            'video_id' => (string)$this->input('video_id', 0),
            'course_id' => (string)$this->input('course_id', 0),
            'company_id' =>(int)$user['login_company_id'],
            'attaches' => (array)$this->input('attaches',[]),
        ];
    }
}
